package com.briup.estore.web.servlet;

import com.briup.estore.common.result.Result;
import com.briup.estore.common.utils.JsonUtils;
import com.briup.estore.service.ShopCarService;
import com.briup.estore.service.impl.ShopCarServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author briup-adam
 * @Date 2023/8/4 下午4:47
 * @Description 删除购物车数据 支持批量删除
 **/
@WebServlet("/shopCar/del")
public class ShopCarDelServlet extends  BaseServlet {
    private ShopCarService shopCarService=new ShopCarServiceImpl();

    @Override
    protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String data = readData(req);
         int[] ids = JsonUtils.toObject(data, int[].class);
        shopCarService.deleteByIds(ids);
        writeData(resp, Result.success());

    }
}
